package com_7;

import java.util.*;

/*
思路：1，HsahMap集合对牌进行储存
       2，创建Arraylist集合存储扑克牌的编号
       3，创建TreeSet给三个选手进行发牌，也就是遍历
       4，构造方法进行看牌
 */
public class Test2 {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        ArrayList<Integer> arr = new ArrayList<>();
        String[] colors = {"!", "@", "#", "$"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
        int index = 0;
        for (String color : colors) {
            for (String number1 : number) {
                map.put(index, color + number1);
                arr.add(index);
                index++;
            }
        }
        map.put(index, "小王");
        arr.add(index);
        index++;
        map.put(index, "大王");
        Collections.shuffle(arr);
        TreeSet<Integer> a = new TreeSet<>();
        TreeSet<Integer> b = new TreeSet<>();
        TreeSet<Integer> c = new TreeSet<>();
        TreeSet<Integer> d = new TreeSet<>();
        for (int i = 0; i < arr.size(); i++) {
            Integer poker = arr.get(i);
            if (i >= arr.size()-3) {
                a.add(poker);
            } else if (i % 3 == 0) {
                b.add(poker);
            } else if (i % 3 == 1) {
                c.add(poker);
            } else if (i % 3 == 2) {
                d.add(poker);
            }
        }
        lookPoker("底牌", a, map);
        lookPoker("诸葛亮", b, map);
        lookPoker("周瑜", c, map);
        lookPoker("小乔", d, map);
    }
    public static void lookPoker(String name, TreeSet<Integer> set, HashMap<Integer, String> map) {
        System.out.print(name + "的牌是：");
        for (Integer key : set) {
            String poker = map.get(key);
            System.out.print(poker);
        }
        System.out.println();
    }
}
